import React, {Component} from 'react';
import "./index.css"
class Parent extends Component {
    render() {
        return (
            <div className="parent">
                <h2>我是A组件</h2>
                <A render={(name)=><B name={name}/>}>
                    hello
                </A>
            </div>
        );
    }
}

class A extends Component {
    state = {
        name:'xxx'
    }


    render() {
        const {name} = this.state
        return (
            <div className="a">
                <h2>我是B组件</h2>
                {
                    this.props.children
                }
                {
                    this.props.render(name)
                }
                <B/>
            </div>
        );
    }
}

class B extends Component {
    render() {
        return (
            <div className="b">
                <h2>我是C组件</h2>
                {
                    this.props.name
                }
            </div>
        );
    }
}

export default Parent;


